package com.xl.innerclass3;

public class Test {
    public static void main(String[] args) {
        Animal a = new Cat();
        a.eat();

        //把这个匿名内部类编译成一个子类，然后立即创建一个子类对象出来
        Animal b = new Animal(){
            public void eat() {
                System.out.println("匿名类吃鱼");
            }
        };
        b.eat();
    }
}

class Cat extends Animal {
    public void eat() {
        System.out.println("吃鱼");
    }
}

abstract class Animal {
    public abstract void eat();
}
